package com.ocean.web.controller.product;

import java.util.List;

import com.ocean.productDict.domain.OProductLateTime;
import com.ocean.productDict.service.IOProductLateTimeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ocean.common.annotation.Log;
import com.ocean.common.enums.BusinessType;
import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.utils.poi.ExcelUtil;
import com.ocean.common.core.page.TableDataInfo;

/**
 * 晚传显示Controller
 *
 * @author ocean
 * @date 2023-01-11
 */
@Controller
@RequestMapping("/product/lateTime")
public class OProductLateTimeController extends BaseController
{
    private String prefix = "product/time";

    @Autowired
    private IOProductLateTimeService oProductLateTimeService;

    @RequiresPermissions("product:time:view")
    @GetMapping()
    public String time()
    {
        return prefix + "/time";
    }

    /**
     * 查询晚传显示列表
     */
    @RequiresPermissions("product:time:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OProductLateTime oProductLateTime)
    {
        startPage();
        List<OProductLateTime> list = oProductLateTimeService.selectOProductLateTimeList(oProductLateTime);
        return getDataTable(list);
    }

    /**
     * 导出晚传显示列表
     */
    @RequiresPermissions("product:time:export")
    @Log(title = "晚传显示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OProductLateTime oProductLateTime)
    {
        List<OProductLateTime> list = oProductLateTimeService.selectOProductLateTimeList(oProductLateTime);
        ExcelUtil<OProductLateTime> util = new ExcelUtil<OProductLateTime>(OProductLateTime.class);
        return util.exportExcel(list, "晚传显示数据");
    }

    /**
     * 新增晚传显示
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存晚传显示
     */
    @RequiresPermissions("product:time:add")
    @Log(title = "晚传显示", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OProductLateTime oProductLateTime)
    {
        return toAjax(oProductLateTimeService.insertOProductLateTime(oProductLateTime));
    }

    /**
     * 修改晚传显示
     */
    @RequiresPermissions("product:time:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        OProductLateTime oProductLateTime = oProductLateTimeService.selectOProductLateTimeById(id);
        mmap.put("oProductLateTime", oProductLateTime);
        return prefix + "/edit";
    }

    /**
     * 修改保存晚传显示
     */
    @RequiresPermissions("product:time:edit")
    @Log(title = "晚传显示", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OProductLateTime oProductLateTime)
    {
        return toAjax(oProductLateTimeService.updateOProductLateTime(oProductLateTime));
    }

    /**
     * 删除晚传显示
     */
    @RequiresPermissions("product:time:remove")
    @Log(title = "晚传显示", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(oProductLateTimeService.deleteOProductLateTimeByIds(ids));
    }
}
